#pragma once
#include <queue>

class BlockQueue
{
public:
    BlockQueue(int cap)
        : _cap(cap)
    {
        pthread_mutex_init(&_lock, nullptr);
        pthread_cond_init(&_full_cond, nullptr);
        pthread_cond_init(&_empty_cond, nullptr);
    }
    ~BlockQueue()
    {
        pthread_mutex_destroy(&_lock);
        pthread_cond_destroy(&_full_cond);
        pthread_cond_destroy(&_empty_cond);
    }
private:
    std::queue<pthread_t> _q;
    int _cap;
    pthread_mutex_t _lock;
    pthread_cond_t _full_cond;
    pthread_cond_t _empty_cond;
};